package task

import (
	"sync"

	"gitee.com/ggtony/folder-scan/filescan"
)

func Filefound(mf *filescan.Myfile, MaxLine chan struct{}, wg *sync.WaitGroup) {
	MaxLine <- struct{}{}
	defer func() {
		<-MaxLine
	}()
	filescan.Scan(mf)
	if mf.KidDirCount > 0 {
		for _, v := range mf.KidNode {

			switch v.Mftype {
			case "Dir":
				{
					wg.Add(1)
					go func(mf *filescan.Myfile, m chan struct{}) {
						defer wg.Done()
						Filefound(v, MaxLine, wg)
					}(v, MaxLine)
				}
			default:
				continue
			}
		}
	} else {
		return
	}

}
